﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using System;
/// <summary>
/// 浮动文字
/// </summary>
public class FloatingText : MonoBehaviour
{
    public string text;
    private Text damageText;
    private RectTransform rectTransform;
    // Start is called before the first frame update
    void Start()
    {
        damageText = GetComponentInChildren<Text>();
        rectTransform = GetComponent<RectTransform>();
        rectTransform.DOAnchorPosY(50, 1f).SetRelative().OnComplete(DestorySelf);
        damageText.DOFade(0, 1);
        damageText.text = text;
    }

    private void DestorySelf()
    {
        Destroy(gameObject);
    }

    public void SetText(string text)
    {
        this.text = text;
    }
}
